package UIFree.graphicTools.color.palettes
{
	import UIFree.uif_component;
	
	import UIUtils.uif_color;
	
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	
	public class uif_gradientPaletteView extends uif_basePaletteView {
		private var _baseColor: uint = 0xFF0000;
		
		public function uif_gradientPaletteView(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:Object='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
		}
		
		public function get baseColor(): uint {
			return _baseColor;
		}
		
		public function set baseColor(a_color: uint): void {
			_baseColor = a_color;
			updatePalette();
		}
		
		override public function get stepSize(): Number {
			return width / 16;
		}
		
		override protected function drawPalette(a_bmd: BitmapData): void {
			var r: Rectangle = new Rectangle(0, 0, stepSize, stepSize);
			while (r.y < a_bmd.height) {
				r.x = 0;
				while (r.x < a_bmd.width) {
					var ix: Number = r.x / a_bmd.width;
					var iy: Number = 1 - r.y / a_bmd.height;
					var color: uint = uif_color.computeRGBA(0, uif_color.computeRGBA(0xFFFFFF, _baseColor, ix), iy); 
					a_bmd.fillRect(r, color);
					r.x += r.width;
				}
				r.y += r.height;
			}
		}
	}
}